home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / basic / gtshape.lha / GTShape_Fixes / gtshape_fix.asc next >
Text File  |  1999-02-28  |  2KB  |  91 lines

  1. ; Description:  Example of GTShape gadgets not working and how to fix them.
  2. ; Type:         Intuition
  3. ;
  4. ; BUGS:         Well, there should be one with the image highlighted gadgets,
  5. ;               in that the correct image is not shown for all gadgets.
  6. ;               Strange then that the bug is that it actually works properly!
  7.  
  8. DEFTYPE.w
  9. WBStartup
  10.  
  11. WbToScreen 0
  12. WBenchToFront_
  13.  
  14. ; Create a bitmap for grabbing shapes from
  15. BitMap 0,16,16,4
  16.  
  17. ; Draw first shape - a 16 colour image. GTShapes normally only let you
  18. ; display 4 colours. Make sure your workbench is at least 16 colour.
  19. For i.w=0 To 3
  20.     For j.w=0 To 3
  21.         Boxf j*4,i*4,j*4+4,i*4+4,i*4+j
  22.     Next
  23. Next
  24. GetaShape 0,0,0,16,16
  25.  
  26. ; The four remaining shapes are to illustrate the problem with different
  27. ; highlight shapes in Blitz 2. All highlight shapes end up as the last one
  28. ; used. The two gadgets should be:
  29. ;   (un)filled rectangle when (un)selected
  30. ;   (un)filled circle when (un)selected
  31. ; These are shapes which only use less than the fourth colour, but it
  32. ; is possible to add the two problems (i.e. <>4 colour shapes with shape
  33. ; highlights)
  34. Cls
  35. Box 2,2,13,13,1
  36. GetaShape 1,0,0,16,16
  37. Boxf 2,2,13,13,1
  38. GetaShape 2,0,0,16,16
  39.  
  40. Cls
  41. Circle 8,8,4,1
  42. GetaShape 3,0,0,16,16
  43. Circlef 8,8,4,1
  44. GetaShape 4,0,0,16,16
  45.  
  46. ; Now create our problem gadgets
  47. GTShape 0,0,10,30,0,0
  48. GTShape 0,1,30,30,0,1,2
  49. GTShape 0,2,50,30,0,3,4
  50.  
  51. ; And our fixed gadgets
  52. ; First of all, fix the <>4 colour problem
  53. GTShape 0,3,160,30,0,0
  54. *g.Gadget=GTGadPtr(0,3)     ; Get pointer to gadget
  55. *gi.Image=*g\GadgetRender   ; Get pointer to image of unselected gadget
  56. *s.shape=Addr Shape(0)      ; Pointer to shape we have used as image
  57. new_planepick.b=0
  58. For i=0 To *s\_depth-1
  59.     new_planepick = new_planepick | (1 LSL i)
  60. Next
  61. *gi\PlanePick = new_planepick
  62.  
  63. GTShape 0,4,180,30,0,1,2
  64. GTShape 0,5,200,30,0,3,4
  65.  
  66. Window 0,0,0,320,200,#WFLG_SIZEGADGET|#WFLG_ACTIVATE|#WFLG_CLOSEGADGET|#WFLG_DRAGBAR|#WFLG_DEPTHGADGET,"Test",-1,-1
  67. DefaultOutput
  68.  
  69. AttachGTList 0,0
  70.  
  71. ; Print some headings
  72. WLocate 10,10
  73. NPrint "Problem gadgets"
  74. WLocate 150,10
  75. NPrint "Fixed gadgets"
  76. ;For i=0 To 4
  77. ;    WBlit i,i*20,100
  78. ;Next
  79.  
  80. While ev.l<>#IDCMP_CLOSEWINDOW
  81.     ev=WaitEvent
  82.     Select ev
  83.         Case #IDCMP_GADGETUP
  84.             NPrint "Gadget hit=",GadgetHit
  85.     End Select
  86. Wend
  87.  
  88. DetachGTList 0
  89. End
  90.  
  91.